import Common from "../Common";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Navbar extends Common {

    @property()
    title: string

    titleLabel: cc.Label

    backBtn: cc.Node

    start() {
        this.backBtn = this.node.getChildByName('back')
        this.titleLabel = this.node.getChildByName('title').getComponent(cc.Label)
        if (this.title) {
            this.titleLabel.string = this.title
        }
        this.backBtn.on(cc.Node.EventType.TOUCH_START, () => {
            this.onBtnClick()
            this.goToHall()
        }, this)
    }

    init(title: string) {
        this.title = title
        this.titleLabel.string = title
    }
}
